package com.zx.BookSeaReader.greendao;


import com.zx.BookSeaReader.application.MyApplication;
import com.zx.BookSeaReader.greendao.gen.DaoMaster;
import com.zx.BookSeaReader.greendao.gen.DaoSession;
import com.zx.BookSeaReader.greendao.util.MySQLiteOpenHelper;

/**
 * @Author: ZX
 * @Time: 2020/2/15
 * @Description: greendao管理
 */

public class GreenDaoManager {
    private static GreenDaoManager instance;
    private static DaoMaster daoMaster;
    private static MySQLiteOpenHelper mySQLiteOpenHelper;

    public static GreenDaoManager getInstance() {
        if (instance == null) {
            instance = new GreenDaoManager();
        }
        return instance;
    }

    public GreenDaoManager(){
        mySQLiteOpenHelper = new MySQLiteOpenHelper(MyApplication.getmContext(), "booksea" , null);
        daoMaster = new DaoMaster(mySQLiteOpenHelper.getWritableDatabase());
    }



    public DaoSession getSession(){
       return daoMaster.newSession();
    }

}
